/*
 * @Description: 空页面
 * @Version: V1.0.0
 * @Author: 黄鑫
 * @Date: 2025-04-15
 * @LastEditors: 黄鑫
 * @LastEditTime: 2025-05-27
 * @FilePath: EmptyFailView.dart
 * @Remarks: 
 */
import 'package:flutter/material.dart';
import 'package:hx_base/resource/Assets.dart';

class EmptyFailView extends StatelessWidget {
  ///提示
  final String tip;

  ///图片路径
  final String? imageName;

  ///点击事件
  final Function()? onTap;

  ///图片宽度
  final double imageWidth;

  ///图片高度
  final double imageHeight;

  const EmptyFailView(
      {this.tip = "数据加载失败...",
      this.imageName,
      this.imageWidth = 150,
      this.imageHeight = 150,
      this.onTap,
      super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Image.asset(
            imageName ?? Assets.imagesNoDataIcon,
            width: imageWidth,
            height: imageHeight,
            package: imageName == null ? "hx_base" : null,
          ),
          Text(
            tip,
            style: const TextStyle(
              fontSize: 12,
              color: Color(0xFF666666),
            ),
          ),
          Visibility(
            visible: onTap != null,
            child: TextButton(
              onPressed: () {
                onTap!();
              },
              child: const Text(
                "重新加载",
                style: TextStyle(
                  fontSize: 12,
                  color: Color(0xFF28CCCB),
                ),
              ),
            ),
          )
        ],
      ),
    );
  }
}
